<%--
  Created by IntelliJ IDEA.
  User: 敬潘
  Date: 2021/7/2
  Time: 15:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增</title>
</head>
<body>
    <form action="AddBoking" method="post">
        <table border="1">
            <tr>
                <td colspan="2"><h2>添加疫苗接种预约信息</h2></td>
            </tr>
            <tr>
                <td>预约人姓名(*)</td>
                <td><input type="text" name="userName" id="userName"
                           required="required" /></td>
            </tr>
            <tr>
                <td>预约人身份证号(*)</td>
                <td><input type="text" id="cardId" name="cardId"
                           required="required" /><span id="info"></span></td>
            </tr>
            <tr>
                <td>预约人日期(*)</td>
                <td><input type="text" name="bookingDate" required="bookingDate"
                           pattern="(\d{4})-(\d{1,2})-(\d{1,2})" /></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="提交" /></td>
            </tr>

        </table>
        <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
        <script type="text/javascript">
            $("#cardId").blur(function() {
                $.post("FindById", "cardId=" + $("#cardId").val(), findById);
            });
            function findById(bookingDate) {
                if (data == "false") {
                    $("#info").html("该人员已接种或预约接种疫苗!");
                }
            }
            $("form").submit(function() {
                var comms = $("form").serialize();
                alert(comms)
                $.post("InsertServlet", comms, addBack());
            });
            function addBack(bookingDate) {
                if (data == "1") {
                    alert("增加成功");
                } else {
                    alert("增加失败");
                }
            }
        </script>
    </form>
</body>
</html>
